﻿using DAL;
using Model;

namespace BLL
{
    public class FoodBLL
    {
        /// <summary>
        /// 依赖注入
        /// </summary>
        private readonly FoodDAL dal;

        public FoodBLL(FoodDAL dal)
        {
            this.dal = dal;
        }
        /// <summary>
        /// 显示食谱类的所有信息
        /// </summary>
        /// <returns></returns>
        public IQueryable<FoodType> Getall()
        {
            try
            {
                return dal.Getall();
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 新增食谱信息
        /// </summary>
        /// <param name="info">食谱类</param>
        /// <returns></returns>
        public int Add(Food info)
        {
            try
            {
                return dal.Add(info);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 显示+查询
        /// </summary>
        /// <param name="name">食谱标题</param>
        /// <param name="tid">食谱类</param>
        /// <returns></returns>
        public IQueryable<DTO> Show(string? name, int tid = -1)
        {
            try
            {
                return dal.Show(name, tid);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
